#!/bin/env python

import time
import cv2

windowName = "video"

# cv2.namedWindow(windowName, cv2.WINDOW_NORMAL)
# cv2.resizeWindow(windowName, 640, 480)

cap = cv2.VideoCapture(0)

if cap.isOpened():
    while True:
        ret, frame = cap.read()
        if not ret: break

        cv2.imshow(windowName, frame)
        if cv2.waitKey(10) == ord('q'):
            break
else:
    print("Error: VideoCapture failed")

print('销毁窗口')
cap.release()
cv2.destroyAllWindows()